package com.shelpe.services.sinbadgateway.repository.jpa;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.shelpe.services.sinbadgateway.entity.jpa.Users;

public interface UsersRepository extends CrudRepository<Users, Long> {

	Users findTopByUserId(Long userId);
	
	Users findTopByNickOrderByUserIdDesc(String nick);
	
	@Modifying(clearAutomatically = true)
	@Transactional
	@Query("update Users u set u.init = ?2, u.userType = ?3 where u.userId = ?1")  
	int updateUser(long userId, int init, int userType);
}
